package com.hongxun.project.assets.iPullLine.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hongxun.framework.aspectj.lang.annotation.Log;
import com.hongxun.framework.aspectj.lang.enums.BusinessType;
import com.hongxun.project.assets.iPullLine.domain.IPullLine;
import com.hongxun.project.assets.iPullLine.service.IIPullLineService;
import com.hongxun.framework.web.controller.BaseController;
import com.hongxun.framework.web.page.TableDataInfo;
import com.hongxun.framework.web.domain.AjaxResult;
import com.hongxun.common.utils.poi.ExcelUtil;

/**
 * 拉线 信息操作处理
 * 
 * @author hongxun
 * @date 2019-03-19
 */
@Controller
@RequestMapping("/assets/iPullLine")
public class IPullLineController extends BaseController
{
    private String prefix = "assets/iPullLine";
	
	@Autowired
	private IIPullLineService iPullLineService;
	
	@RequiresPermissions("assets:iPullLine:view")
	@GetMapping()
	public String iPullLine()
	{
	    return prefix + "/iPullLine";
	}
	
	/**
	 * 查询拉线列表
	 */
	@RequiresPermissions("assets:iPullLine:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(IPullLine iPullLine)
	{
		startPage();
        List<IPullLine> list = iPullLineService.selectIPullLineList(iPullLine);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出拉线列表
	 */
	@RequiresPermissions("assets:iPullLine:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(IPullLine iPullLine)
    {
    	List<IPullLine> list = iPullLineService.selectIPullLineList(iPullLine);
        ExcelUtil<IPullLine> util = new ExcelUtil<IPullLine>(IPullLine.class);
        return util.exportExcel(list, "iPullLine");
    }
	
	/**
	 * 新增拉线
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存拉线
	 */
	@RequiresPermissions("assets:iPullLine:add")
	@Log(title = "拉线", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(IPullLine iPullLine)
	{		
		return toAjax(iPullLineService.insertIPullLine(iPullLine));
	}

	/**
	 * 修改拉线
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") String id, ModelMap mmap)
	{
		IPullLine iPullLine = iPullLineService.selectIPullLineById(id);
		mmap.put("iPullLine", iPullLine);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存拉线
	 */
	@RequiresPermissions("assets:iPullLine:edit")
	@Log(title = "拉线", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(IPullLine iPullLine)
	{		
		return toAjax(iPullLineService.updateIPullLine(iPullLine));
	}
	
	/**
	 * 删除拉线
	 */
	@RequiresPermissions("assets:iPullLine:remove")
	@Log(title = "拉线", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(iPullLineService.deleteIPullLineByIds(ids));
	}
	
}
